 <a name="wikitocoolsolutionsconverter"></a><h1>Wiki to CoolSolutions Converter</h1>
 <a name="abitofphpatasteofregularexpressionsthatsit"></a><h2>A bit of Php, a taste of regular expressions... That's it!</h2>
  Have an idea to share on CoolSolutions? Don't want to use to much time writing it with HTML tags? Use the Wiki format! I adapted a Wiki parser written in Php from <a href="http://code.blitzaffe.com" target="_blank"> http://code.blitzaffe.com</a>. I added some styles that were not included such as blockquotes, callouts, tables with headers and table of contents. 

<br/><br/>

 This document shows the different Wiki constructions you can use to write your CoolSolutions. I wrote this article using all the Wiki components available. 

<br/><br/>

 <a name="contentoftheattachedarchive"></a><h3>Content of the attached archive</h3>
 Here is the content of the file wiki2cool.zip: 

<br/><br/>

<pre class="code">./wiki2cool
  +- WikiParser.php
  +- convert.php
  +- index.php
  +- main.css
  +- tier4.css
  +- Wiki2Cool_OnlineConverter_1.png
  +- Wiki2Cool_OnlineConverter_2.png
  +- Wiki2Cool_OnlineConverter_3.png
  +- Wiki2Cool_Sections.png
  +- article.txt
  +- article.html
 </pre>


<br/><br/>

 Details: 

<br/><br/>

 <ul>
<li><code>WikiParser.php</code>: class used to parse Wiki text. This class has been updated to handle Novell classes such as "callout" on div tags, "spread" class for lists, "code" class for preformatted text and inline code and also new tables components.</li>
 <li><code>convert.php</code>: script to convert Wiki text file on the command line. To use it, execute "<code>convert.php article.txt > article.html</code>".</li>
 <li><code>index.php</code>: if you copy all the files to a Apache/Php folder, this page will offer you an online page to convert and preview Wiki content to HTML. You can also try <a href="http://wiki2cool.kalfane.org" target="_blank"> http://wiki2cool.kalfane.org</a> if it is available. It is an install of my files on an accessible public web server. Use it to test your Wiki content!</li>
 <li><code>*.css</code>: files to have a Novell style for index.php. It is not fully like the CoolSolutions website but it is close to it.</li>
 <li><code>*.png</code>: images included in this article to illustrate sections, table of contents and the online converter</li>
 <li><code>article.txt</code>: the source code of this article in Wiki format!</li>
 <li><code>article.html</code>: the final HTML code of this article</li>
 </ul>


<br/><br/>

 <a name="sections"></a><h3>Sections</h3>
 To create a section, just surround your line with one or more equal signs according to the level. You can generate a Table of Contents automatically if you put <code>{{__TOC__}}</code> <strong>at the end</strong> of the document. Then, when you generate the HTML, you can move it to the beginning of the document. 

<br/><br/>

 If you use the following: 

<br/><br/>

<pre class="code">= This is the Title =
== This is the Sub-Title ==
=== Introduction ===
Lorem ipsum lorem ipsum ipsum lorem ipsum
=== Part 1 ===
==== Sub-Part 1 ====
Lorem ipsum lorem ipsum ipsum lorem ipsum
==== Sub-Part 2 ====
Lorem ipsum lorem ipsum ipsum lorem ipsum
=== Part 2 ===
Lorem ipsum lorem ipsum ipsum lorem ipsum
=== Summary ===
Lorem ipsum lorem ipsum ipsum lorem ipsum
{{__TOC__}}
 </pre>


<br/><br/>

 The result will magically be: 

<br/><br/>

 <img src="/communities/files/u3740/Wiki2Cool_Sections.png" alt="Screenshot of the result" align="center"/>

 

<br/><br/>

 <a name="displayingtexts"></a><h3>Displaying Texts</h3>
 If you type text on several lines, they will be joined by default unless there is two line returns, which means a new paragraph, or if you force the line return using the code "<code>///</code>".  

<br/><br/>

 For instance if you type the following: 

<br/><br/>

<pre class="code">This is regular text. 
The second line is in the same paragraph.

It is also possible to force///line breaks
 </pre>


<br/><br/>

 The result will be the following: 

<br/><br/>

 This is regular text.  The second line is in the same paragraph. 

<br/><br/>

 It is also possible to force<br/>
line breaks 

<br/><br/>

 You can also format code inline by surrounding it with dollars "$": 

<br/><br/>

<pre class="code">$convert.php$: script to convert Wiki text to HTML
 </pre>


<br/><br/>

 The result will be the following: 

<br/><br/>

 <code>convert.php</code>: script to convert Wiki text to HTML 

<br/><br/>

 To display a separator, use 4 dashes "----": 

<br/><br/>

<pre class="code">Text above separator
----
Text under separator
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 Text above separator <hr /> Text under separator 

<br/><br/>

 There several level of emphasis you can use by surrounding the text with multiple quotes: 

<br/><br/>

<pre class="code">* ''level 2 emphasis''
* '''level 3 emphasis'''
* ''''level 4 emphasis''''
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <ul>
<li><em>level 2 emphasis</em></li>
 <li><strong>level 3 emphasis</strong></li>
 <li><em><strong>level 4 emphasis</strong></em></li>
 </ul>


<br/><br/>

 <a name="displayingdefinitionlists"></a><h3>Displaying Definition Lists</h3>
 Use ";" and ":" separator to display terms and definitions: 

<br/><br/>

<pre class="code">; '''yes''' : opposite of no
; '''no''' : opposite of yes
; '''maybe'''
: somewhere in between yes and no
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <dl>
<dt><strong>yes</strong> </dt><dd> opposite of no</dd> <dt><strong>no</strong> </dt><dd> opposite of yes</dd> <dt><strong>maybe</strong></dt> <dd>somewhere in between yes and no</dd>
 </dl>


<br/><br/>

 <a name="indentingtext"></a><h3>Indenting text</h3>
 Use ":" to indent text: 

<br/><br/>

<pre class="code">Normal
: indented
: more indentation
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 Normal <dl>
<dd>indented</dd>
 <dd>more indentation</dd>
 </dl>
<a name="displayingcode"></a><h3>Displaying Code</h3>
 To display preformatted code add a space at the beginning of the lines: 

<br/><br/>

<pre class="code">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;nodes&gt;
  &lt;node id=&quot;node1&quot;/&gt;
  &lt;node id=&quot;node2&quot;/&gt;
  &lt;node id=&quot;node3&quot;/&gt;
  &lt;node id=&quot;node4&quot;/&gt;
&lt;/nodes&gt;
 </pre>


<br/><br/>

 Another one: 

<br/><br/>

<pre class="code">34 '''print''' &quot;Listing filtered files v2 (list comprehension)&quot;
35 dir = &quot;.&quot;
36 ext = &quot;py&quot;
37 files = [f &lt;b&gt;for&lt;/b&gt; f &lt;b&gt;in&lt;/b&gt; os.listdir( dir ) '''if''' re.search('^.*.' + ext + '$',f) ]
38 '''print''' &quot;n&quot;.join( files )
39 '''print''' &quot;Found %d .%s file(s) in current directory&quot; % ( len( files ), ext )
40 '''print''' &quot;&quot;
 </pre>


<br/><br/>

 <a name="displayingimages"></a><h3>Displaying Images</h3>
  You can display images using the following format: <img src="url" alt="text"/>

. The image can be aligned on the left with text on the right, aligned on the right with text on the left or centered with text under it. 

<br/><br/>

 For instance: 

<br/><br/>

<pre class="code">[[Image:http://www.novell.com/communities/sites/all/themes/novell/images/icons/feature.gif|right|CoolSolution Icon]]
Conectitur contumeliae, interesse meminerimus poenis sapiens. Aenean aeque dominationis eodem invenire malesuada paulo. Aegritudinem careret didicisse disciplinae discordant, emancipaverat ferant infimum laboramus nos oblivione officiis rudem sadipscing solum. Arte atque dicitur efficere fingitur gratissimo partem quamvis unum. Angatur asperiores compositis discordant, excelsus ipse magnis nemore, no reperiuntur suum vicinum videri. 

[[Image:http://www.novell.com/communities/sites/all/themes/novell/images/icons/feature.gif|left|CoolSolution Icon]]
Conectitur contumeliae, interesse meminerimus poenis sapiens. Aenean aeque dominationis eodem invenire malesuada paulo. Aegritudinem careret didicisse disciplinae discordant, emancipaverat ferant infimum laboramus nos oblivione officiis rudem sadipscing solum. Arte atque dicitur efficere fingitur gratissimo partem quamvis unum. Angatur asperiores compositis discordant, excelsus ipse magnis nemore, no reperiuntur suum vicinum videri. 
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <img src="http://www.novell.com/communities/sites/all/themes/novell/images/icons/feature.gif" alt="CoolSolution Icon" align="right"/>

 Conectitur contumeliae, interesse meminerimus poenis sapiens. Aenean aeque dominationis eodem invenire malesuada paulo. Aegritudinem careret didicisse disciplinae discordant, emancipaverat ferant infimum laboramus nos oblivione officiis rudem sadipscing solum. Arte atque dicitur efficere fingitur gratissimo partem quamvis unum. Angatur asperiores compositis discordant, excelsus ipse magnis nemore, no reperiuntur suum vicinum videri.  

<br/><br/>

 <img src="http://www.novell.com/communities/sites/all/themes/novell/images/icons/feature.gif" alt="CoolSolution Icon" align="left"/>

 Conectitur contumeliae, interesse meminerimus poenis sapiens. Aenean aeque dominationis eodem invenire malesuada paulo. Aegritudinem careret didicisse disciplinae discordant, emancipaverat ferant infimum laboramus nos oblivione officiis rudem sadipscing solum. Arte atque dicitur efficere fingitur gratissimo partem quamvis unum. Angatur asperiores compositis discordant, excelsus ipse magnis nemore, no reperiuntur suum vicinum videri.  

<br/><br/>

 If you have a look at the WikiParser.php file, you can extend the features by adding your own Wiki components. For instance I added a spacial one: 

<br/><br/>

<pre class="code">{*cool_solutions}
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <img src="http://www.novell.com/communities/sites/all/themes/novell/images/coolheader.png" alt="<strong>{*cool_solutions}</strong>" align="center"/>

 

<br/><br/>

 <a name="displayinglists"></a><h3>Displaying Lists</h3>
 <a name="unorderedlist"></a><h4><strong>Unordered list</strong></h4>
 Use stars "*" followed by space to build your normal or multi-level unordered lists: 

<br/><br/>

<pre class="code">* list
* list
** list
** list
* list
* list
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <ul>
<li>list</li>
 <li>list</li>
 <ul>
<li>list</li>
 <li>list</li>
 </ul>
<li>list</li>
 <li>list</li>
 </ul>
<a name="unorderedlistspreadclass"></a><h4><strong>Unordered list, spread class</strong></h4>
 Use "o" followed by space to build your normal or multi-level unordered lists with spread class: 

<br/><br/>

<pre class="code">o list
o list
oo list
oo list
o list
o list
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <ul class="spread">
<li>list</li>
 <li>list</li>
 <ul class="spread">
<li>list</li>
 <li>list</li>
 </ul class="spread">
<li>list</li>
 <li>list</li>
 </ul>
<a name="orderedlist"></a><h4><strong>Ordered list</strong></h4>
 Use sharps "#" followed by space to build your normal or multi-level ordered lists: 

<br/><br/>

<pre class="code"># list
# list
## list
## list
## list
# list
## list
## list
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <ol>
<li>list</li>
 <li>list</li>
 <ol>
<li>list</li>
 <li>list</li>
 <li>list</li>
 </ol>
<li>list</li>
 <ol>
<li>list</li>
 <li>list</li>
 </ol>
</ol>
<a name="mixedlist"></a><h4><strong>Mixed list</strong></h4>
 You can mix ordered and unordered lists: 

<br/><br/>

<pre class="code">* One bullet
* Another '''bullet'''
*# a list item
*# another list item
*#* unordered, ordered, unordered
*#* again
*# back down one
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <ul>
<li>One bullet</li>
 <li>Another <strong>bullet</strong></li>
 <ol>
<li>a list item</li>
 <li>another list item</li>
 <ul>
<li>unordered, ordered, unordered</li>
 <li>again</li>
 </ul>
<li>back down one</li>
 </ol>
</ul>


<br/><br/>

 <a name="displayingblockquotesandcallouts"></a><h3>Displaying blockquotes and callouts</h3>
 To display callouts use "@" character at the beginning of the lines: 

<br/><br/>

<pre class="code">@'''Note:'''
@This is a callout.
@Use &quot;@&quot; at the beginning of each line.
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <div class="callout"><strong>Note:</strong><br/>
 This is a callout.<br/>
 Use "@" at the beginning of each line.<br/>
 </div>


<br/><br/>

 To display blockquote use percent "%" character at the beginning of the lines: 

<br/><br/>

<pre class="code">%'''Note:'''
%This is a blockquote.
%Use &quot;%&quot; at the beginning of each line.
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <blockquote><strong>Note:</strong><br/>
 This is a blockquote.<br/>
 Use "%" at the beginning of each line.<br/>
 </blockquote><br clear="all"/>
<a name="displayinglinks"></a><h3>Displaying Links</h3>
 You can display external links in 3 different manners: <ul>
<li>Note Link</li>
 <li>Normal Link</li>
 <li>Labeled Link</li>
 </ul>


<br/><br/>

 For instance: 

<br/><br/>

<pre class="code">Note Link: Go to Novell[http://www.novell.com] or Novell Support[http://support.novell.com]!

Normal Link: [http://www.novell.com http://www.novell.com]

Labeled Link: [http://www.novell.com Novell Website]
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 Note Link: Go to Novell<a href="http://www.novell.com" target="_blank">[1]</a> or Novell Support<a href="http://support.novell.com" target="_blank">[2]</a>! 

<br/><br/>

 Normal Link: <a href="http://www.novell.com" target="_blank"> http://www.novell.com</a> 

<br/><br/>

 Labeled Link: <a href="http://www.novell.com" target="_blank"> Novell Website</a> 

<br/><br/>

 <a name="displayingtables"></a><h3>Displaying Tables</h3>
 <a name="withoutheader"></a><h4><strong>Without header</strong></h4>
 Using the "!" separator, you can easily display basic table without header: 

<br/><br/>

<pre class="code">!aaa!bbb!ccc!ddd!eee
!aaa!bbb!ccc!ddd!eee
!aaa!bbb!ccc!ddd!eee
!aaa!bbb!ccc!ddd!eee
!aaa!bbb!ccc!ddd!eee
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <table><tr class="even"><td>aaa</td><td>bbb</td><td>ccc</td><td>ddd</td><td>eee</td></tr>
 <tr class="odd"><td>aaa</td><td>bbb</td><td>ccc</td><td>ddd</td><td>eee</td></tr>
 <tr class="even"><td>aaa</td><td>bbb</td><td>ccc</td><td>ddd</td><td>eee</td></tr>
 <tr class="odd"><td>aaa</td><td>bbb</td><td>ccc</td><td>ddd</td><td>eee</td></tr>
 <tr class="even"><td>aaa</td><td>bbb</td><td>ccc</td><td>ddd</td><td>eee</td></tr>
 </table>


<br/><br/>

 <a name="withhorizontalheader"></a><h4><strong>With horizontal header</strong></h4>
 Use pipe "|" separator on the first line to display horizontal header: 

<br/><br/>

<pre class="code">| aaa | bbb | ccc | ddd | eee 
! aaa ! bbb ! ccc ! ddd ! eee 
! aaa ! bbb ! ccc ! ddd ! eee 
! aaa ! bbb ! ccc ! ddd ! eee 
! aaa ! bbb ! ccc ! ddd ! eee 
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <table><tr class="even"><th> aaa </th><th> bbb </th><th> ccc </th><th> ddd </th><th> eee </th></tr>
 <tr class="odd"><td> aaa </td><td> bbb </td><td> ccc </td><td> ddd </td><td> eee </td></tr>
 <tr class="even"><td> aaa </td><td> bbb </td><td> ccc </td><td> ddd </td><td> eee </td></tr>
 <tr class="odd"><td> aaa </td><td> bbb </td><td> ccc </td><td> ddd </td><td> eee </td></tr>
 <tr class="even"><td> aaa </td><td> bbb </td><td> ccc </td><td> ddd </td><td> eee </td></tr>
 </table>


<br/><br/>

 <a name="withverticalheader"></a><h4><strong>With vertical header</strong></h4>
 Use underscore "_" separator at the beginning of each line to display vertical header: 

<br/><br/>

<pre class="code">_ aaa ! aaa ! aaa ! aaa ! aaa 
_ bbb ! bbb ! bbb ! bbb ! bbb 
_ ccc ! ccc ! ccc ! ccc ! ccc 
_ ddd ! ddd ! ddd ! ddd ! ddd 
_ eee ! eee ! eee ! eee ! eee 
 </pre>


<br/><br/>

 Here is the result of the conversion from Wiki to HTML: 

<br/><br/>

 <table><tr class="even"><th> aaa </th><td> aaa </td><td> aaa </td><td> aaa </td><td> aaa </td></tr>
 <tr class="odd"><th> bbb </th><td> bbb </td><td> bbb </td><td> bbb </td><td> bbb </td></tr>
 <tr class="even"><th> ccc </th><td> ccc </td><td> ccc </td><td> ccc </td><td> ccc </td></tr>
 <tr class="odd"><th> ddd </th><td> ddd </td><td> ddd </td><td> ddd </td><td> ddd </td></tr>
 <tr class="even"><th> eee </th><td> eee </td><td> eee </td><td> eee </td><td> eee </td></tr>
 </table>


<br/><br/>

 <a name="technicaldetails"></a><h3>Technical Details</h3>
 The <code>WikiParser</code> class analyze the Wiki content line by line and use regular expressions to detect Wiki patterns and convert it to HTML. There are two types or regular expressions used: 

<br/><br/>

 <ul>
<li><strong>line patterns</strong>, to detect for instance preformatted code, lists, definition lists, tables, etc.</li>
 <li><strong>character patterns</strong>, to detect for instance links, emphasizes, inline code, force breaks</li>
 </ul>
<a name="lineshandling"></a><h4><strong>Lines handling</strong></h4>
 Here are the line patterns definitions that was in the original class: 

<br/><br/>

<pre class="code">$line_regexes = array(
	'preformat'=&gt;'^\s(.*?)$',
	'definitionlist'=&gt;'^([\;\:])\s*(.*?)$',
	'newline'=&gt;'^$',
	'list'=&gt;'^([\*\#]+)(.*?)$',
	'sections'=&gt;'^(={1,6})(.*?)(={1,6})$',
	'horizontalrule'=&gt;'^----$',
);
 </pre>


<br/><br/>

 In the new class I added blockquotes, callouts, tables, coolbanner and table of contents: 

<br/><br/>

<pre class="code">$line_regexes = array(
	'preformat'=&gt;'^\s(.*?)$',
	'blockquote'=&gt;'^%(.*?)$',
	'callout'=&gt;'^@(.*?)$',
	'table'=&gt;'^([!\|_])(.*?)$',
	'definitionlist'=&gt;'^([\;\:])\s*(.*?)$',
	'newline'=&gt;'^$',
	'list'=&gt;'^([\*\#\o]+) (.*?)$',
	'sections'=&gt;'^(={1,6})(.*?)(={1,6})$',
	'horizontalrule'=&gt;'^----$',
	'coolbanner'=&gt;'^\{\*cool_solutions\}$',
	'toc'=&gt;'^\{\{__TOC__\}\}',
);
 </pre>


<br/><br/>

 You can see here that, for instance, blockquotes start with the "%" character, callouts start with the "@" character and tables either with "|", "!" or "_" characters. When you add a new line pattern in this array, for instance "toc", you have to build a function <code>handle_toc</code> that will do something with the regular expression matches. 

<br/><br/>

 To automatically build a Table of Contents, I added some code in the <code>handle_sections</code> that detect the sections and their level to build an array. For each section, I store an array containing the content, the level (to be able to generate h1, h2, etc.) and the anchor which is the content without spaces, without non-alpha characters and all lowercase. 

<br/><br/>

<pre class="code">function handle_sections($matches) {
	$level = strlen($matches[1]);
	$content = trim( $matches[2] );
	$this-&gt;stop = true;
	
	// build the anchor
	$anchor = preg_replace( &quot;/[^a-zA-Z]/&quot;, &quot;&quot;, $content );
	$anchor = strtolower( $anchor );

	// add to toc
	$this-&gt;toc[ $this-&gt;tocnb ] = array( $content, $anchor, $level );
	$this-&gt;tocnb++;

	// avoid accidental run-on emphasis
	return $this-&gt;emphasize_off() . &quot;&lt;a name=\&quot;$anchor\&quot;&gt;&lt;/a&gt;&lt;h{$level}&gt;{$content}&lt;/h{$level}&gt;\n&quot;;
}
 </pre>


<br/><br/>

 Then, when the string <code>{{__TOC__}}</code> is detected, the <code>handle_toc</code> method go through the array (remember the first part of the article about <a href="http://www.novell.com/communities/node/3144/build-your-own-scripts-manipulate-ldif-exports-part-1" target="_blank"> building your own scripts</a>), get the level, anchor that will be prefixed by "#" in the URL and content to build the table: 

<br/><br/>

<pre class="code">function handle_toc($matches) {
	$output = &quot;&lt;h3&gt;Table of Contents&lt;/h3&gt;\n&quot;;
	ksort( $this-&gt;toc );
	foreach( $this-&gt;toc as $k=&gt;$v )
	{
		for( $i = 0 ; $i &lt; $v[2] - 1 ; $i++ ) $output .= &quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;;
		$output .= &quot;&lt;a href=\&quot;#{$v[1]}\&quot;&gt;{$v[0]}&lt;/a&gt;&lt;br/&gt;\n&quot;;
	}
	return $output;
}
 </pre>
<a name="charactershandling"></a><h4><strong>Characters handling</strong></h4>
 Here are the character patterns definition from the original class: 

<br/><br/>

<pre class="code">$char_regexes = array(
	'internallink'=&gt;'('.
		'\[\['. // opening brackets
			'(([^\]]*?)\:)?'. // namespace (if any)
			'([^\]]*?)'. // target
			'(\|([^\]]*?))?'. // title (if any)
		'\]\]'. // closing brackets
		'([a-z]+)?'. // any suffixes
		')',
	'externallink'=&gt;'('.
		'\['.
			'([^\]]*?)'.
			'(\s+[^\]]*?)?'.
		'\]'.
		')',
	'emphasize'=&gt;'(\'{2,5})',
	'eliminate'=&gt;'(__TOC__|__NOTOC__|__NOEDITSECTION__)',
	'variable'=&gt;'('. '\{\{' . '([^\}]*?)' . '\}\}' . ')',
);
 </pre>


<br/><br/>

 In the new class I removed some of them and added code and forcebeaks: 

<br/><br/>

<pre class="code">$char_regexes = array(
	'internallink'=&gt;'('.
		'\[\['. // opening brackets
			'(([^\]]*?)\:)?'. // namespace (if any)
			'([^\]]*?)'. // target
			'(\|([^\]]*?))?'. // title (if any)
		'\]\]'. // closing brackets
		'([a-z]+)?'. // any suffixes
		')',
	'externallink'=&gt;'('.
		'\['.
			'([^\]]*?)'.
			'(\s+[^\]]*?)?'.
		'\]'.
		')',
	'emphasize'=&gt;'(\'{2,4})',
	'code'=&gt;'(\$(.+?)\$)',
	'forcebreak'=&gt;'(\/\/\/)',
I);
 </pre>


<br/><br/>

 Once again, if you add a new character pattern, like "code" or "forcebreak", you have to define the methods <code>handle_code</code> and <code>handle_forcebreak</code> as the following (these are very simple): 

<br/><br/>

<pre class="code">function handle_forcebreak($matches) {
	return &quot;&lt;br/&gt;\n&quot;;
}

function handle_code($matches) {
	return &quot;&lt;code&gt;&quot;.$matches[2].&quot;&lt;/code&gt;&quot;;
}
 </pre>
<a name="conclusion"></a><h3>Conclusion</h3>
 I hope that you will be able to write your CoolSolutions article faster thanks to the Wiki format.  

<br/><br/>

 You can convert your files on the command line using the following command: 

<br/><br/>

<pre class="code">wiki2cool&gt; ./convert.php article.txt &gt; article.html
 </pre>


<br/><br/>

 Don't hesitate to use the online converter available at <a href="http://wiki2cool.kalfane.org" target="_blank"> http://wiki2cool.kalfane.org</a> or install one on your server by just copying the content of the archive in an Apache/Php folder. You will be able to select different samples depending on what you want to see. Here are some screenshots: 

<br/><br/>

 <img src="/communities/files/u3740/Wiki2Cool_OnlineConverter_1.png" alt="Online converter 1"/>

 

<br/><br/>

 Here is the result of the submission: 

<br/><br/>

 <img src="/communities/files/u3740/Wiki2Cool_OnlineConverter_2.png" alt="Online converter 2"/>

 

<br/><br/>

 <img src="/communities/files/u3740/Wiki2Cool_OnlineConverter_3.png" alt="Online converter 3"/>

 

<br/><br/>

 Also don't hesitate to have a look at the Wiki source of this article that you will find in the file article.txt.  If you add new Wiki components in the WikiParser class, keep me posted!  Happy writing! 

<br/><br/>

 <h3>Table of Contents</h3>
<a href="#wikitocoolsolutionsconverter">Wiki to CoolSolutions Converter</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#abitofphpatasteofregularexpressionsthatsit">A bit of Php, a taste of regular expressions... Thats it!</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#contentoftheattachedarchive">Content of the attached archive</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sections">Sections</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#displayingtexts">Displaying Texts</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#displayingdefinitionlists">Displaying Definition Lists</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#indentingtext">Indenting text</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#displayingcode">Displaying Code</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#displayingimages">Displaying Images</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#displayinglists">Displaying Lists</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#unorderedlist">Unordered list</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#unorderedlistspreadclass">Unordered list, spread class</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#orderedlist">Ordered list</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#mixedlist">Mixed list</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#displayingblockquotesandcallouts">Displaying blockquotes and callouts</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#displayinglinks">Displaying Links</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#displayingtables">Displaying Tables</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#withoutheader">Without header</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#withhorizontalheader">With horizontal header</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#withverticalheader">With vertical header</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#technicaldetails">Technical Details</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#lineshandling">Lines handling</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#charactershandling">Characters handling</a><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#conclusion">Conclusion</a><br/>
 

<br/><br/>

